package cn.gogetter.clusterer;

import java.io.File;

import weka.clusterers.EM;
import weka.core.Instances;
import weka.core.converters.ArffLoader;
// 批量训练EM算法【期望最大化(Expectation Maximization)算法】
public class BatchClusterer {
	public static void main(String[] args){
		// 加载数据
		Instances data = null;
		String path = new File("").getAbsolutePath()+"\\data\\";
		ArffLoader loader = new ArffLoader();
		try {
			loader.setFile(new File(path + "contact-lenses.arff"));
			data = loader.getDataSet();
			// 构建聚类器
			String[] options = new String[2];
			options[0] = "-I";
			options[1] = "100";
			EM clusterer = new EM();
			clusterer.setOptions(options);
			clusterer.buildClusterer(data);
			
			// 输出生成模型
			System.out.println(clusterer);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
